package momall.item.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import cc.momas.momall.po.TbItem;
import cc.momas.momall.po.TbItemDesc;
import cc.momas.momall.service.IItemDescService;
import cc.momas.momall.service.IItemService;
import momall.item.web.vo.Item;

/**
 * 商品详情页展示Controlelr
 * @author sod
 *
 */
@Controller
public class ItemController {

	@Autowired
	private IItemService itemService;
	@Autowired
	private IItemDescService itemDescService;
	
	@RequestMapping("/item/{itemId}.html")
	public String showItemInfo(@PathVariable Long itemId,Model model) {
		//调用服务取商品基本信息
		TbItem tbItem = itemService.getItemById(itemId);
		Item item = new Item(tbItem);
		//取商品描述信息
		TbItemDesc itemDesc = itemDescService.getById(itemId);
		
		//把信息传递给页面
		model.addAttribute("item",item);
		model.addAttribute("itemDesc",itemDesc);
		return "item";
	}
	
}
